home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Instance.sea / XML Instance / Required / plugins / HTMLWindow.jar / horst / HTMLPane$ToolTip.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-18  |  2.0 KB  |  47 lines

  1. package horst;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.FontMetrics;
  7. import java.awt.Frame;
  8. import java.awt.Graphics;
  9. import java.awt.SystemColor;
  10. import java.awt.Window;
  11.  
  12. class HTMLPane$ToolTip extends Window {
  13.    // $FF: synthetic field
  14.    private final HTMLPane this$0;
  15.    String text;
  16.  
  17.    HTMLPane$ToolTip(HTMLPane this$0, String text) {
  18.       super(new Frame());
  19.       this.this$0 = this$0;
  20.       this.this$0 = this$0;
  21.       this.text = text;
  22.       ((Component)this).setForeground(SystemColor.textText);
  23.       ((Component)this).setBackground(Color.yellow);
  24.    }
  25.  
  26.    public Dimension getPreferredSize() {
  27.       Graphics g = ((Component)this).getGraphics();
  28.       FontMetrics fm = g.getFontMetrics();
  29.       return new Dimension(fm.stringWidth(this.text) + 4, fm.getHeight() + 4);
  30.    }
  31.  
  32.    public void paint(Graphics g) {
  33.       Dimension size = ((Component)this).getSize();
  34.       FontMetrics fm = g.getFontMetrics();
  35.       g.drawRect(0, 0, size.width - 1, size.height - 1);
  36.       if (this.text.length() > 0) {
  37.          g.drawString(this.text, 2, fm.getAscent() + 2);
  38.       }
  39.  
  40.    }
  41.  
  42.    public void show() {
  43.       ((Window)this).pack();
  44.       super.show();
  45.    }
  46. }
  47.